Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avkr003/leverage improvements #752

Merged
merged 21 commits into from
Aug 29, 2024
Merged

Conversation

avkr003
Copy link
Contributor

@avkr003 avkr003 commented Aug 26, 2024

Key Changes:

  • Earlier when adding a pool to leverage LP, we were not validating with module params max allowed and when opening position, we were directly comparing to module params from user tx. Now, we set pool leverage max by comparing with module params and while opening position, we compare with pool leverage max, not module params max. Add Pool Open position

  • CheckAndLiquidateUnhealthyPosition and CheckAndCloseAtStopLoss always return an error if the position is not closed. Changed return variable earlyReturn to closeAttempted and changed logic everywhere else accordingly. earlyReturn was ambiguous where it was returning from. closeAttempted returns true if ForceCloseLong has been called in the function.

  • Remove IsPoolEnabled and IsPoolClosed functions as it was adding a pool without any governance proposal

  • Added msg basic validations

    • In msg_close_positions, not allowing repeating close position IDs including both stop loss and unhealthy positions

    • 0 stop loss price while opening position is allowed indicating not set by the user. (based on testnet app) here

    • Not allow same position ids while claiming rewards here

    • Params validation:

      • Not allowing negative leverage max
      • PoolOpenTheshold has to be always +ve (0 not allowed)

x/leveragelp/keeper/begin_blocker.go Outdated Show resolved Hide resolved
x/leveragelp/keeper/begin_blocker.go Show resolved Hide resolved
x/leveragelp/keeper/begin_blocker.go Show resolved Hide resolved
x/leveragelp/keeper/begin_blocker.go Show resolved Hide resolved
x/leveragelp/keeper/msg_server_close_positions.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 94.23077% with 9 lines in your changes missing coverage. Please review.

Project coverage is 42.44%. Comparing base (59a34a6) to head (832f4df).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #752      +/-   ##
==========================================
+ Coverage   40.37%   42.44%   +2.06%     
==========================================
  Files         627      626       -1     
  Lines       20347    20387      +40     
==========================================
+ Hits         8216     8654     +438     
+ Misses      11107    10736     -371     
+ Partials     1024      997      -27     
Components Coverage Δ
leveragelp_transactions 84.89% <100.00%> (+32.26%) ⬆️
leveragelp_lifecycle 88.29% <94.11%> (+24.16%) ⬆️
leveragelp_keeper 47.67% <0.00%> (+4.05%) ⬆️
leveragelp_queries 17.80% <ø> (ø)
accountedpool_transactions 100.00% <ø> (ø)
accountedpool_lifecycle ∅ <ø> (∅)
accountedpool_queries 68.42% <ø> (ø)
amm_transactions 57.93% <ø> (ø)
amm_lifecycle 79.16% <ø> (ø)
amm_keeper 61.13% <ø> (ø)
amm_queries 29.94% <ø> (ø)
assetprofile_transactions 78.82% <ø> (ø)
assetprofile_lifecycle ∅ <ø> (∅)
assetprofile_keeper 83.33% <ø> (ø)
assetprofile_queries 47.41% <ø> (ø)
burner_transactions 0.00% <ø> (ø)
burner_lifecycle ∅ <ø> (∅)
burner_keeper 100.00% <ø> (ø)
burner_queries 63.54% <ø> (ø)
clock_transactions 30.00% <ø> (ø)
clock_lifecycle ∅ <ø> (∅)
clock_keeper 76.92% <ø> (ø)
clock_queries ∅ <ø> (∅)
commitment_transactions 48.95% <ø> (ø)
commitment_lifecycle ∅ <ø> (∅)
commitment_keeper 19.60% <ø> (ø)
commitment_queries 9.33% <ø> (ø)
epochs_transactions ∅ <ø> (∅)
epochs_lifecycle 100.00% <ø> (ø)
epochs_keeper 81.81% <ø> (ø)
epochs_queries 85.71% <ø> (ø)
estaking_transactions 48.64% <ø> (ø)
estaking_lifecycle 71.23% <ø> (ø)
estaking_keeper 63.05% <ø> (ø)
estaking_queries 55.31% <ø> (ø)
incentive_transactions 0.00% <ø> (ø)
incentive_lifecycle ∅ <ø> (∅)
incentive_keeper 0.00% <ø> (ø)
incentive_queries ∅ <ø> (∅)
masterchef_transactions 63.63% <ø> (ø)
masterchef_lifecycle 73.75% <ø> (ø)
masterchef_keeper 89.47% <ø> (ø)
masterchef_queries 45.97% <ø> (ø)
oracle_transactions 30.00% <ø> (ø)
oracle_lifecycle 0.00% <ø> (ø)
oracle_keeper 63.88% <ø> (ø)
oracle_queries 34.95% <ø> (ø)
parameter_transactions 15.11% <100.00%> (+15.11%) ⬆️
parameter_lifecycle ∅ <ø> (∅)
parameter_keeper 75.00% <ø> (ø)
parameter_queries 60.00% <ø> (ø)
stablestake_transactions 73.91% <ø> (ø)
stablestake_lifecycle 75.00% <ø> (ø)
stablestake_keeper 71.42% <ø> (ø)
stablestake_queries 13.04% <ø> (ø)
tier_transactions 28.57% <ø> (ø)
tier_lifecycle 100.00% <ø> (ø)
tier_keeper 90.47% <ø> (ø)
tier_queries 22.50% <ø> (ø)
tokenomics_transactions 72.32% <ø> (ø)
tokenomics_lifecycle ∅ <ø> (∅)
tokenomics_keeper 83.33% <ø> (ø)
tokenomics_queries 70.96% <ø> (ø)
transferhook_transactions ∅ <ø> (∅)
transferhook_lifecycle ∅ <ø> (∅)
transferhook_keeper 100.00% <ø> (ø)
transferhook_queries 60.00% <ø> (ø)

@cosmic-vagabond cosmic-vagabond merged commit cfc04bd into main Aug 29, 2024
71 checks passed
@cosmic-vagabond cosmic-vagabond deleted the avkr003/leverageImprovements branch August 29, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants